#include <iostream>
using namespace std;
int main(){
	int t;
	cin>>t;
	while(t--){
	int n,m,sum,x;
	cin>>n>>m;
	sum=n*m;
	while(m){
		int k;
		k=n%m;
		n=m;
		m=k;
	}
	x=sum/n;
	cout<<n<<" "<<x<<endl;	
	}
}
